;*****************************************************************************
;    ______        __                  ______                     __  __   __
;   / __  /       / /                 / __  /  ELBOX Update      / /  \ \ / /
;  / /  -'__  __ / /___ ______ _____ / /_ -'_____ ______ ______ / /__  \ \ /
; / /     \ \/ // __  // ____// .__// // \ / .__// __  // __  // __  / /  /  V3
;/ /___    \  // /_/ // __/_ / /   / /_/ // /   / __  // /_/ // / / / / \ \
;\____/    / //_____//_____//_/   /_____//_/   /_/ /_// ____//_/ /_/ /_/ \_\
;         /_/                                        / /
;                                                   /_/
; S3           : Generic ViRGE 86C325 & ViRGE/DX 82C375 Driver
;          
; CyberGraphX V3 1997-2000 Vision Factory Development
; CyberGraphX V3 Update Installer 1995,1996,1997,1998,1999,2000 by Robert C. Reiswig 
; Mediator 2000 by Elbox
; $VER: V0.78 (Oct-25-2000)
; 
; If you wish to use any part of this installer you must ask. May not be 
; integrated/placed into any other package! You may NOT change this in an way!
; You man NOT take or use the ENV definitions and use them without direct
; permission from me! Changes, suggestions or problems: rob@cgx.vgr.com
;********************************************************************************



;********************************************************************************
; Cyber Release & Boards
;********************************************************************************
(set @user-level 2)
(set #cyberver "V3 41.2")
(set NoBoard 0)
(set whereback "SYS:Storage")
(message (cat "CyberGraphX " #cyberver "\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
              "Generic PCI\n\nViRGE (86C325) / ViRGE/DX (86C375)\n\ndrivers for the Elbox Mediator"
         )
)

(welcome)
;********************************************************************************
; Read All System information
;********************************************************************************
(set cpu (database "cpu")) (if (> (exists ("sys:libs/68060.library")) 0) (set cpu "68060") )
(set vblank (database "vblank")) (set graphmem (database "graphics-mem"))
(set totmem (database "total-mem")) (set osver (/ (getversion "LIBS:version.library") 65536))
(if (= vblank "60") ((set blank "NTSC")) ((set blank "PAL")))
(set fastmem (- totmem graphmem))
( if (= osver 37) ( (set workbench "2.0")) ( if (= osver 38) ( (set workbench "2.1"))
( if (= osver 39) ( (set workbench "3.0")) ( if (= osver 40) ( (set workbench "3.1"))
( if (= osver 41) ( (set workbench "3.2")) )))))
(set pick 0)

;********************************************************************************
;English Strings
;********************************************************************************
(set #By (cat "\n\nCyberGraphX\n\nRelease Version " #cyberver "\n\n\n\n"
              "by:\n\nVision Factory Development"
          
         )
)
(set #nobackup "\n\nThis installer will copy the correct new V3 Libs and Monitor to the correct places. It will not do any backup currently.\n\nThis will not install V3 for the first time, it just _updates_ a V3 system.")
(set #askzorro "\nWhat type of machine is CyberGraphX V3 installed on?\n")
(set #askcpu "\nWhat CPU does the machine have that you are updating CyberGraphX V3 on? The installer has found:\n")
(set #wherelibs "Where are your CyberGraphX V3 libraries located? The default is 'SYS:Libs'")
(set #whatboard (cat "Please Select the Graphics Board you wish to update CyberGraphX Monitor File for:"))
(set #todo-prompt "\nDo you wish to install:\n")
(set #cgxmode-todo " CGXMode - Create & Change Screen Modes")
(set #wheremode "Where do you wish to copy the CGXMode Program?")
(set #whereshowcgxconfig "Where do you wish to copy the ShowCGXconfig Program?")
(set #showcgxconfig " ShowCGXconfig - CGX Info Program")
;*********** NEW English Strings:  Monday 01-Dec-97 *************************
(set #nocgxmode "\n\nOne of the graphic card(s) you selected does not currently support the use of CGXMode.\n\nA2410 or AGA(PPC)\n\nCGXMode can be use with all of the other CyberGraphX supported cards!")
;*********** NEW English Strings:  Wednesday 21-Jan-98 **********************
(set #updatep4flash "\nTo use CyberGraphX with the Picasso IV you should be running version 2.0 or greater of the Picasso IV FlashROM.\n\nThe installer has found a version lower then 2.0.\n\nForm more information and newer FlashROMs you can contact:\nYour Dealer\nVillage Tronic\nVillage Tronic Web site\n")
;*********** NEW English Strings:  Wednesday 11-Mar-98 **********************
(set #noppc1 "\n\nYou selected the PPC option for one of your CPUs. The installer did not find the 'libs:PPC.library'.\n\nCyberGraphX may not work correctly.\n\n Do you wish to reselect the CPU type?")
(set #noppcaga "\nYou selected the 'AGA (PPC Only)' option when picking what graphics card (display device) to use with CyberGraphX. The installer did not find the 'libs:PPC.library'.\n\n The AGACGX driver needs a PPC card installed to work correctly.\n\nDo you wish to Abort the install now?.")
(set #agaquit "\nCyberGraphX install/update exiting.")

;*********** NEW English Strings: Monday 28-Aug-00 14:57:13 **********************
(set #cgxv4 (cat "\nCheck out CyberGraphX V4 at:\nhttp://www.vgr.com/v4\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
                 "\n- Includes -\nCustom drivers for each PCI Elbox Card\nHardware blitter support\nCGXVideo support\nCGX Prefs Program\nLatest CGXMode\nCGXMode monitor database\nFully compatible with CGX V3\n68040 version of the CGX library")
)


;********************************************************************************
;German Strings by the King!
;********************************************************************************
(if (= @language "deutsch")
(
 (set #nobackup "\n\nDieses Installationsskript kopiert die neuen V3 Bibliotheken und Monitore in die entsprechenden Verzeichnisse. Es wird keine Sicherung vorgenommen.\n\nEs ist keine V3 Erstinstallation, das V3 System wird nur _erneuert_ .")
 (set #askzorro "\nWelche Erweiterungsslots besitzt der Computer, auf dem Sie CyberGraphX V3 installieren ?\n")
 (set #askcpu "\nWelchen Prozessor besitzt der Computer, auf dem Sie CyberGraphX V3 installieren wollen ? Der installer hat folgendes gefunden:\n")
 (set #wherelibs "Wo befinden sich die CyberGraphX V3 Bibliotheken ? Standard ist 'SYS:Libs'")
 (set #whatboard (cat "Bitte whlen Sie die Grafikkarte, deren CyberGraphX Monitordatei erneuern wollen:"))
 (set #todo-prompt "\nWelches der folgenden Programme wollen Sie installieren: ?\n")
 (set #cgxmode-todo " CGXMode - Erstellen & ndern von Bildschirmmodis")
 (set #wheremode "Wohin wollen Sie das CGXMode Programm kopiert haben?")
 (set #whereshowcgxconfig "Wohin wollen Sie das ShowCGXconfig Programm kopiert haben?")
 (set #showcgxconfig " ShowCGXconfig - CyberGraphX Informationsprogramm")
 ;*********** NEW German Strings:  Monday 01-Dec-97 *************************
 (set #nocgxmode "\n\nEine/Mehrere Grafikkarte(n), die Sie ausgewhlt haben, wird/werden von CGXMode momentan nicht untersttzt.\n\nA2410 oder AGA(PPC)\n\nCGXMode kann mit allen anderen Karten, die CyberGraphX untersttzt, jedoch benutzt werden!")
 ;*********** NEW English Strings:  Wednesday 21-Jan-98 **********************
 (set #updatep4flash "\nUm CyberGraphX3 mit der PicassoIV zu benutzen, sollten sie auf jeden Fall die Version 2.0 oder grer des PicassoIV FlashROMs installieren.\n\nDas Installationsskript entdeckte eine ltere Version.\n\nFr weitere Informationen und eine neuere FlashROM Version kontaktieren Sie bitte:\nIhren Hndler\nVillageTronic\ndie VillageTronic WWW Seite\n")
)
)

;********************************************************************************
; French Strings by Gregory Eycken <geycken@geocities.com>
;********************************************************************************
(if (= @language "franais")
(
 (set #nobackup "\n\nCe script d'installation va copier les nouvelles bibliothques et les nouveaux moniteurs de CyberGraphX V3 aux endroits adquats. Il n'effectuera aucun archivage.\n\nCe script n'est pas prvu pour installer CyberGraphX V3 pour la premire fois, il ne peut faire que la _mise  jour_ d'un systme CyberGraphX V3 existant.")
 (set #askzorro "\nSur quel type d'ordinateur CyberGraphX V3 est-il install?\n")
 (set #askcpu "\nQuel est le processeur de l'ordinateur sur lequel vous voulez mettre  jour CyberGraphX V3? L'installeur a trouv :\n")
 (set #wherelibs "O sont installes les bibliothques de CyberGraphX V3? Par dfaut, c'est 'SYS:Libs'.")
 (set #whatboard (cat "Veuillez slectionner la carte graphique dont vous voulez mettre le fichier moniteur  jour :"))
 (set #todo-prompt "\nDsirez-vous installer :\n")
 (set #cgxmode-todo " CGXMode - Crer et modifier les modes d'cran")
 (set #wheremode "O dsirez-vous installer le programme CGXMode?")
 (set #whereshowcgxconfig "O dsirez-vous installer le programme ShowCGXconfig?")
 (set #showcgxconfig " ShowCGXconfig - Programme d'informations CyberGraphX")
)
)

;********************************************************************************
; Start Update
;********************************************************************************
;(message #by)
(message #nobackup)


;*******************************************************************
; ASK what board to update
;*******************************************************************
(set BGuess 0) (set AGA 0)

(if (> (exists ("devs:monitors/MediatorViRGE")) 0)  (set BGuess (+ BGuess 1)) )


  (set board (askoptions (choices  " MediatorViRGE"  
                          (prompt #whatboard)
	                  (help #whatboard)
                          (default BGuess)
                         )
             )     
  )


;********************************************************************
; Double Check on the CPU
;********************************************************************
(procedure askaboutcpu

(set cpu (database "cpu"))
(if (= cpu 68000) (set #cpu 0)) (if (= cpu 68010) (set #cpu 0))
(if (= cpu 68020) (set #cpu 0)) (if (= cpu 68030) (set #cpu 0))
(if (= cpu 68040) (set #cpu 1)) (if (= cpu 68060) (set #cpu 1)) 
(if (= @installer-version 0)
  (if (> (exists ("sys:libs/68060.library")) 0) (set #cpu 1) )
  (if (= cpu 68060) (set #cpu 1))
)
(if (> (exists ("libs:PPC.library")) 0) (set #cpu 2) )

(set cpuPick (askchoice (choices "68020 or 68030" "68040 or 68060")
			(prompt #askcpu)
	                (help   #askcpu)
          		(default #cpu)
	  )
)

(if (= cpuPick 0) ((set cpuadd ".020") (set cpuadd-1 ".020")) ) 
(if (= cpuPick 1) ((set cpuadd ".040") (set cpuadd-1 ".040")) )

)

;(askaboutcpu)
(set cpuadd ".020") (set cpuadd-1 ".020")

;*******************************************************************
;  ASK where cybergfx libs are
;*******************************************************************
(set wherelibs   (askdir (prompt #wherelibs)
			 (help   #wherelibs)
 		         (default "SYS:Libs")
		 )
)

;*******************************************************************
;  Copy libs if there
;*******************************************************************
(if (exists (tackon "cgxsystemlib" (cat "cgxsystem.library" cpuadd-1)) )
  (copyfiles (source (tackon "cgxsystemlib" (cat "cgxsystem.library" cpuadd-1))) (dest wherelibs) (newname "cgxsystem.library") (optional "nofail") ) 
)

(if (exists (tackon "cgxmpeglib" (cat "cgxmpeg.library" cpuadd)) )
  (copyfiles (source (tackon "cgxmpeglib" (cat "cgxmpeg.library" cpuadd))) (dest wherelibs) (newname "cgxmpeg.library") (optional "nofail") ) 
)


(if (AND (exists "cgxbootpiclib/cgxbootpic.library") (= 0 (exists "libs:cgxbootpic.library")) )
  (copyfiles (source "cgxbootpiclib/cgxbootpic.library") (dest wherelibs) (optional "nofail") ) 
)

;*******************************************************************
;  Installer monitor file and handle extra libs 
;*******************************************************************
  (if (IN board 0)
   (
     (set zadd "")

     (if (exists (tackon "S3Drivers" (cat "MediatorViRGE" zadd)))
      (if (= (exists (tackon "devs:monitors" "MediatorViRGE.info")) 0)      
       (copyfiles (source (tackon "S3Drivers" (cat "MediatorViRGE" zadd))) (dest "devs:monitors") (infos) (optional "nofail") ) 
       (copyfiles (source (tackon "S3Drivers" (cat "MediatorViRGE" zadd))) (dest "devs:monitors") (optional "nofail") ) 
      )      
     )

     (if (exists (tackon "cgxvideolib" (cat "cgxvideo.library" cpuadd)) )
       (copyfiles (source (tackon "cgxvideolib" (cat "cgxvideo.library" cpuadd))) (dest wherelibs) (newname "cgxvideo.library") (optional "nofail") ) 
     )

     (if (exists (tackon "cgx3dvirgelib" (cat "cgx3dvirgin.library" "")) )
       (copyfiles (source (tackon "cgx3dvirgelib" (cat "cgx3dvirgin.library" ""))) (dest wherelibs) (newname "cgx3dvirgin.library") (optional "nofail") ) 
     )

   )
  )

 

;*********************************************************************************
;* Ask user to install CGXMode 
;*********************************************************************************
(set toolpick 3)

(if (OR (IN board 8) (IN board 10)) ;**Check&Msg for non CGXMode Drivers.
 ( 
  (message #nocgxmode)
  (set toolpick 2)
 )
)

(set ToDo (askoptions (choices #cgxmode-todo #showcgxconfig)
                      (prompt #todo-prompt)
                      (help #todo-prompt)
                      (default toolpick)
          )
) 

(if (IN ToDo 0) 
  ( 
    (set wheremode   (askdir (prompt #wheremode)
                             (help   #wheremode)
	                     (default "SYS:Prefs")
		     )
    )

    (if (exists "CGXMode/CGXMode")
     (if (= (exists (tackon wheremode "CGXMode.info")) 0)
      (copyfiles (source "CGXMode/CGXMode")  (dest wheremode) (infos) (optional "nofail")) 
      (copyfiles (source "CGXMode/CGXMode")  (dest wheremode) (optional "nofail"))          
     )
    )

    ;(if (IN board 0)  (set TTBOARD "MediatorViRGE") ) 

    ;(if (> board 0)
    ;  (tooltype	(dest (tackon wheremode "CGXMode")) (settooltype "BOARD" TTBOARD) ) 
    ;)

    (if (= @language "deutsch")
     (
       (if (= (exists "Locale:Catalogs") 0) (makedir "sys:Locale/Catalogs") )
       (if (= (exists (tackon "Locale:Catalogs" "deutsch")) 0) (makedir (tackon "sys:Locale/Catalogs" "deutsch")) )
       (if (exists "CGXMode/catalogs/deutsch/cgxmode.catalog")
         (copyfiles (source "CGXMode/catalogs/deutsch/cgxmode.catalog") (dest "sys:Locale/Catalogs/deutsch") )
       )
     )
    )

  )
)


(if (IN ToDo 1) 
  ( 
    (set whereshowcgxconfig   (askdir (prompt #whereshowcgxconfig)
                             (help   #whereshowcgxconfig)
	                     (default "SYS:Tools")
		     )
    )

    (if (exists "tools/showcgxconfig")
     (if (= (exists (tackon whereshowcgxconfig "CGXMode.info")) 0)
      (copyfiles (source "tools/showcgxconfig")  (dest whereshowcgxconfig) (infos) (optional "nofail")) 
      (copyfiles (source "tools/showcgxconfig")  (dest whereshowcgxconfig) (optional "nofail"))          
     )
    )

  )
)
 




;*******************************************************************
;  END
;*******************************************************************
(message #cgxv4)

(if (> (exists ("c:multiview")) 0) (set #mpath "c:") )
(if (> (exists ("sys:Utilities/multiview")) 0) (set #mpath "sys:Utilities") )

(run (cat "run " #mpath "/multiview ReadMe.txt") )

(set @default-dest "sys:")

(set #done "Update Complete!")
(if (= @language "deutsch") (set #done "Update fertig!") )

(exit #done)
